file_picker_callback = function (callback, value, meta) {
    // Provide file and text for the link dialog
    if (meta.filetype == 'file') {
        callback('mypage.html', {text: 'My text'});
    }
    // Provide image and alt text for the image dialog
    if (meta.filetype == 'image') {
        callback('myimage.jpg', {alt: 'My alt text'});
    }
    // Provide alternative source and posted for the media dialog
    if (meta.filetype == 'media') {
        callback('movie.mp4', {source2: 'alt.ogg', poster: 'image.jpg'});
    }

    //文件分类
    var filetype = '.pdf, .txt, .zip, .rar, .7z, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .mp3, .mp4';
    //后端接收上传文件的地址
    var upurl = '/upload/';
    //为不同插件指定文件类型及后端地址
    switch (meta.filetype) {
        case 'image':
            filetype = '.jpg, .jpeg, .png, .gif';
            break;
        case 'media':
            filetype = '.mp3, .mp4';
            break;
        case 'file':
        default:
    }
    //模拟出一个input用于添加本地文件
    var input = document.createElement('input');
    input.setAttribute('type', 'file');
    input.setAttribute('accept', filetype);
    input.click();
    input.onchange = function () {
        var file = this.files[0];
        // 图片上传方式
        var xhr, formData;
        xhr = new XMLHttpRequest();
        xhr.withCredentials = false;
        xhr.open('POST', upurl);
        xhr.onload = function () {
            var json;
            if (xhr.status == 403) {
                failure('HTTP Error: ' + xhr.status, {remove: true});
                return;
            }
            if (xhr.status < 200 || xhr.status >= 300) {
                failure('HTTP Error: ' + xhr.status);
                return;
            }
            json = JSON.parse(xhr.responseText);
            if (!json) {
                failure('Invalid JSON: ' + xhr.responseText);
                return;
            }
            if (json.error) {
                failure('Invalid JSON: ' + json.message);
                return;
            }
            success(json.url);
        };
        formData = new FormData();
        formData.append('file', file, file.name);
        xhr.send(formData);
    }
}